package com.csun.cmny.provider.consumer.message.jpush;

import cn.jpush.api.JPushClient;
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.PushPayload;
import com.csun.cmny.config.properties.CmnyProperties;
import com.csun.cmny.provider.consumer.message.MessageSender;
import com.csun.cmny.provider.model.dto.SendMessageRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2019-11-07 20:42
 * @Description:
 */
@Slf4j
@Service("JPSUH_SHJ_VOLUNTEER")
public class JPushShjVolunteerMessageSender implements MessageSender {

    @Resource
    private CmnyProperties cmnyProperties;
    @Autowired
    private JPushClient shouhjVolunteer;

    /**
     * @param sendMessageRequest
     */
    @Override
    public void sendMessage(SendMessageRequest sendMessageRequest) {

        try {
            PushResult pushResult = shouhjVolunteer.sendPush((PushPayload) sendMessageRequest.getPushPayload());
            log.info("<==== shouhj vounteer push result ====> {}", pushResult.toString());
        } catch (Exception e) {
            log.error("<==== shouhj vounteer push error ====> {}", e.getMessage());
        }
    }
}
